package com.sqoq.downloader3.retrofit;


import io.reactivex.rxjava3.observers.DisposableObserver;

public abstract class BaseObserver<T> extends DisposableObserver<T> {
    protected BaseObserver() {

    }

    @Override
    public void onNext(T response) {
        if (response == null) {
            onHandleError(new Throwable("返回数据为空"));
        } else {
            onHandleSuccess(response);
        }
    }

    @Override
    public void onError(Throwable e) {
        onHandleError(e);
    }

    @Override
    public void onComplete() {

    }

    protected abstract void onHandleSuccess(T response);

    protected abstract void onHandleError(Throwable e);
}
